package control;

import java.sql.ResultSet;
import java.sql.SQLException;

import db.DBConnecter;

public class QueryInfoControl {
	private DBConnecter db;
	
	public QueryInfoControl() {
		db = new DBConnecter();
	}
	
	public String queryInfoCheck(String clientID){
		ResultSet rs;
		String sql = "SELECT COUNT(*) FROM customer WHERE cst_id = '"+clientID+"'";
		try{
			rs = db.query(sql);
			rs.next();//move to first line of the result set
			if(rs.getInt(1) >= 1){//match a user
				
				SessionControl session = new SessionControl();
				session.setSession("myusername", clientID);//insert into session
				return "success";
			}
				
			
		}catch(SQLException e){
			e.printStackTrace();
		}
		return "error";
		
	}
}
